let myRequest = require('./myRequest.js');
let api = require('./api.js');
const app = getApp();
let myAuthorize = function (json, method = '') {
  const that = this;
  myRequest.EasyHttp.post(api.reqUrls.Logininfo, json).then(res => {
    wx.hideLoading();
    if (res.data.status == 1) {
      app.globalData.userInfo = res.data.Data;
      app.globalData.token =  res.data.data.token;
      wx.setStorage({
        key: 'userInfo',
        data: res.data.Data
      })
      typeof method == 'function' && method()
    }else {
      wx.showToast({
        title: res.data.msg,
        icon: 'none',
      })
    }
    
  })
}
module.exports = {
  myAuthorize
}